﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using umbraco.cms.businesslogic.web;
#if UMB45
using umbraco.presentation.nodeFactory;
#else
using umbraco.NodeFactory;
#endif

namespace umbraco.blog4.usercontrols {
    public partial class frmBlogComment : System.Web.UI.UserControl {
        protected void Page_Load(object sender, EventArgs e) {

        }

        /// <summary>
        /// Handles the Click event of the btnSubmit control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnSubmit_Click(object sender, EventArgs e) {
            if (Page.IsValid &&
                (!String.IsNullOrEmpty(txtName.Text)) &&
                (!String.IsNullOrEmpty(txtEmail.Text)) &&
                (!String.IsNullOrEmpty(txtComment.Text)) &&
                BlogLibrary.IsValidEmail(txtEmail.Text)) {
                    Comment c = new Comment(Node.GetCurrent().Id, txtName.Text, txtEmail.Text, txtWebsite.Text, txtComment.Text);
                    Response.Redirect(umbraco.library.NiceUrl(Node.GetCurrent().Id)+"#comment-"+c.Id.ToString());
            }
        }
    }
}
